package com.netty.bfport.http.config.Thread;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import java.util.concurrent.ScheduledFuture;

/**
 * @Author: zhaoyang05
 * @Data: 2022/4/11 13:27
 * @Description
 */
@Component
public class ThreadTaskPool {

    //执行的任务
    public ScheduledFuture<?> schedule;

    //初始化的线程池
    public  volatile ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    {
        scheduler.setPoolSize(20);
        scheduler.setThreadNamePrefix("taskScheduler-");
        scheduler.setWaitForTasksToCompleteOnShutdown(true);
        scheduler.setAwaitTerminationSeconds(60);
        scheduler.initialize();
    }
}
